package br.com.duosoftware.orcamento.daos;

import br.com.duosoftware.orcamento.entidades.Programa;
import java.util.List;

/**
 *
 * @author Daniel
 * 
 */

public class ProgramaDAO extends DAOGenerico{
    
    public void salvarOuAtualizar(Programa programa){
        salvarOuAtualizarPojo(programa);
    }

    public void excluir(Programa programa){
        excluirPojo(programa);
    }

    public Programa getProgramaPorId(long id){
        return getPojo(Programa.class, id);
    }
    
    public Integer getMaxCodigo(){
        return getPojoCriterio("SELECT MAX(CAST(programa.codigo AS integer))"
                             + " FROM Programa programa");
    }
    
    public Programa getProgramaPorCodigo(String codigo){
        return getPojoCriterio("FROM Programa programa WHERE programa.codigo = ? "
                + " ORDER BY programa.id", codigo);
    }
    
    public List<Programa> listarProgramas(){
        return getPojos("FROM Programa programa ORDER BY programa.id");
    }
    
}
